'use strict';

/**
 * Module dependencies.
 */
var users = require('../../app/controllers/users.server.controller'),
	synchupsAndSessions = require('../../app/controllers/synchupsAndSessions.server.controller');

module.exports = function(app) {
	// Sessions Routes
	app.route('/sessions')
		.get(synchupsAndSessions.list)
		.post(users.requiresLogin, synchupsAndSessions.create);

	app.route('/sessions/:sessionId/rateSession')
		.post(synchupsAndSessions.rate);

	app.route('/sessions/:sessionId')
		.get(synchupsAndSessions.read)
		.post(synchupsAndSessions.startSession)
		.put(users.requiresLogin, synchupsAndSessions.hasAuthorization, synchupsAndSessions.update)
		.delete(users.requiresLogin, synchupsAndSessions.userCanUpdateThisSession, synchupsAndSessions.delete);

	app.param('sessionId', synchupsAndSessions.sessionByID);
};
